/**
 * 简单图形引擎
 * Created by gzj on 16/10/12.
 */


class GraphicEngine {
    /**
     *
     * @param canvas {HTMLCanvasElement} 画布
     * @param width {number} 画布宽度
     * @param height {number} 画布高度
     */
    constructor(canvas, width, height) {
        this.canvas = canvas;
        this.canvas.width = width;
        this.canvas.height = height;

        this.ctx = canvas.getContext('2d');
    }

    drawCircle(x, y, radius, color) {
        this.ctx.save();
        this.ctx.strokeStyle = color;
        this.ctx.fillStyle = color;

        this.ctx.beginPath();
        this.ctx.arc(x, y, radius, 0, Math.PI * 2);
        this.ctx.fill();

        this.ctx.restore();
    }

    clearAll() {
        this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
    }
}
